<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>C++ I/O</title>
  <link href="../cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td>
  <div class="body-content">

  <div class="header-box">
    <a href="../index.html">cppreference.com</a> &gt; <a href=
    "index.html">C++ I/O</a>
  </div>

  <div class="name-format">
    C++ I/O
  </div>

  <p>The &lt;iostream&gt; library automatically defines a few standard
  objects:</p>

  <ul>
    <li>cout, an object of the ostream class, which displays data to
    the standard output device.</li>

    <li>cerr, another object of the ostream class that writes
    unbuffered output to the standard error device.</li>

    <li>clog, like cerr, but uses buffered output.</li>

    <li>cin, an object of the istream class that reads data from the
    standard input device.</li>
  </ul>

  <p>The &lt;fstream&gt; library allows programmers to do file input
  and output with the ifstream and ofstream classes.</p>

  <p>C++ programmers can also do input and output from strings by
  using the <a
  href="../cppsstream/index.html">String
  Stream</a> class.</p>

  <p>Some of the behavior of the C++ I/O streams (precision,
  justification, etc) may be modified by manipulating various <a href=
  "../io_flags.html#format_flags">io stream format flags</a>.</p>

  <p>Here are <a href="examples.html">some examples of what you can do
  with C++ I/O</a>.</p>

  <p><a href="all.html">Display all entries</a> for C++ I/O on one
  page, or view entries individually:</p>

  <table class="category-table">
    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="constructors.html">I/O
      Constructors</a></td>

      <td class="category-table-td">constructors</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href="bad.html">bad</a></td>

      <td class="category-table-td">true if an error occurred</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="clear.html">clear</a></td>

      <td class="category-table-td">clear and set status flags</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href="close.html">close</a></td>

      <td class="category-table-td">close a stream</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="eof.html">eof</a></td>

      <td class="category-table-td">true if at the end-of-file</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href="fail.html">fail</a></td>

      <td class="category-table-td">true if an error occurred</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="fill.html">fill</a></td>

      <td class="category-table-td">manipulate the default fill
      character</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href="flags.html">flags</a></td>

      <td class="category-table-td">access or manipulate <a href=
      "../io_flags.html#format_flags">io stream format flags</a></td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="flush.html">flush</a></td>

      <td class="category-table-td">empty the buffer</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href=
      "gcount.html">gcount</a></td>

      <td class="category-table-td">number of characters read during
      last input</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="get.html">get</a></td>

      <td class="category-table-td">read characters</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href=
      "getline.html">getline</a></td>

      <td class="category-table-td">read a line of characters</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="good.html">good</a></td>

      <td class="category-table-td">true if no errors have
      occurred</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href=
      "ignore.html">ignore</a></td>

      <td class="category-table-td">read and discard characters</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="open.html">open</a></td>

      <td class="category-table-td">open a new stream</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href="peek.html">peek</a></td>

      <td class="category-table-td">check the next input character</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href=
      "precision.html">precision</a></td>

      <td class="category-table-td">manipulate the precision of a
      stream</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href="put.html">put</a></td>

      <td class="category-table-td">write characters</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href=
      "putback.html">putback</a></td>

      <td class="category-table-td">return characters to a stream</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href=
      "rdstate.html">rdstate</a></td>

      <td class="category-table-td">returns the state flags of the
      stream</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="read.html">read</a></td>

      <td class="category-table-td">read data into a buffer</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href="seekg.html">seekg</a></td>

      <td class="category-table-td">perform random access on an input
      stream</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="seekp.html">seekp</a></td>

      <td class="category-table-td">perform random access on output
      streams</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href="setf.html">setf</a></td>

      <td class="category-table-td">set format flags</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href=
      "sync_with_stdio.html">sync_with_stdio</a></td>

      <td class="category-table-td">synchronize with standard I/O</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href="tellg.html">tellg</a></td>

      <td class="category-table-td">read input stream pointers</td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="tellp.html">tellp</a></td>

      <td class="category-table-td">read output stream pointers</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href=
      "unsetf.html">unsetf</a></td>

      <td class="category-table-td">clear <a href=
      "../io_flags.html#format_flags">io stream format flags</a></td>
    </tr>

    <tr class="category-table-tr-2">
      <td class="category-table-td"><a href="width.html">width</a></td>

      <td class="category-table-td">access and manipulate the minimum
      field width</td>
    </tr>

    <tr class="category-table-tr-1">
      <td class="category-table-td"><a href="write.html">write</a></td>

      <td class="category-table-td">write characters</td>
    </tr>
  </table>
  </div>
  </td>
  



  </tr>
  </table>
</body></html>
